import '../../../global/tools/json_loader/json_loader_manager.dart';
import '../models/homo_page_category_model.dart';

class YSHHomePageDataSupplier {
  static Future<List<YSHHomePageCategoryModel>?>
      getHomePageCategoryData() async {
    final jsonMap =
        await YSHJsonLoaderManager.loadJsonData('assets/file/category.json');
    // 3.解析Map数据并转成模型
    if (jsonMap != null) {
      final mapList = jsonMap['category'];
      List<YSHHomePageCategoryModel> modelList = [];
      for (var map in mapList) {
        modelList.add(YSHHomePageCategoryModel.fromMap(map));
      }
      return modelList;
    } else {
      return null;
    }
  }
}
